package blueeye.xml
{
	public class XmlHandle
	{
		var xmlstr:String;
		public function XmlHandle()
		{
			 xmlstr = '<?xml version="1.0" ?><blueeye>'
		}
		
		
		public function creatxml(content:String):void
      	{	 	
       		xmlstr += content;
       		xmlstr += "</blueeye>";
	   		
      	}//显示XML
      
      
      
      	public function  openxml(filename:String):XML//文件保存
      	{     
       	    var request:URLRequest = new URLRequest(filename);//获取文件名，不能获取途径所以要同文件夹
         	var xml:XML;
         	var loader:URLLoader = new URLLoader();
        	loader.load(request);
        	loader.addEventListener(Event.COMPLETE,onComplete);
        	function onComplete(event:Event):void
          	{   
          		loader=event.target as URLLoader;
     			if(loader!=null)
      	    	{
       				xml=new XML(loader.data);
        	    }
       	    }
       	    
       	    return xml;
       	}
       
        
      	public function save():void//文件保存 
      	{  
      		var fr:FileReference=new FileReference();
      	   	var myText:ByteArray = new ByteArray();
      	   	myText.writeMultiByte(content.text,"utf-8");
      	   	fr.save(myText);
      	}

	}
}